In [1]:
%pylab inline
matplotlib.rcParams['figure.figsize'] = (10,8)


Populating the interactive namespace from numpy and matplotlib

In [2]:
from cno import cnodata, CNORbool

In [3]:
c = CNORbool(cnodata("PKN-ToyMMB.sif"), cnodata("MD-ToyMMB.csv"))
#c = CNORbool(cnodata("PKN-ExtLiverPCB.sif"), 
#             cnodata("MD-ExtLiverPCB.csv"))
#c = CNORbool(cnodata("PKN-LiverDREAM.sif"), 
#             cnodata("MD-LiverDREAM.csv"))

In [4]:
c.cnograph.png


Out[4]:

Optimisation

Done with a Genetic Algorithm


In [5]:
# the default exammple takes about 5-10 seconds
c.optimise()


{'reltol': 0.1, 'pmutation': 0.5, 'maxstallgens': 100, 'time_index_1': 1, 'popsize': 50, 'elitism': 5, 'selpress': 1.2, 'sizefactor': 0.0001, 'maxgens': 500, 'maxtime': 60, 'NAFac': 1, 'verbose': True}

Warning in Models. found a + sign... in EGF+TNFa=PI3K. Interepreted as ^
Warning in Models. found a + sign... in Raf+!Akt=Mek. Interepreted as ^
Warning in Models. found a + sign... in Erk+TNFa=Hsp27. Interepreted as ^

In [6]:
c.results.results.keys()


Out[6]:
['reactions',
 'models',
 'all_scores',
 'stimuli',
 'all_bitstrings',
 'results',
 'best_score',
 'midas',
 'species',
 'sim_results',
 'best_bitstring',
 'pkn',
 'inhibitors']

The optimal model and score

In the Genetic Algorithm, we have actually a set of models stored as well as the best model


In [7]:
c.results.results['best_bitstring'],c.results.results.reactions


Out[7]:
(array([1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0]),
 ['EGF=PI3K',
  'TNFa=PI3K',
  'Jnk=cJun',
  'PI3K=Akt',
  'Raf=Mek',
  '!Akt=Mek',
  'Mek=p90RSK',
  'Mek=Erk',
  'Erk=Hsp27',
  'TNFa=Jnk',
  'TNFa=NFkB',
  'TNFa=Hsp27',
  'EGF=Raf',
  'EGF^TNFa=PI3K',
  '!Akt^Raf=Mek',
  'Erk^TNFa=Hsp27'])

In [8]:
c.models.scores.min()


Out[8]:
0.0296426065162907

In [9]:
c.models.df.ix[0:2]


Out[9]:
EGF=PI3K TNFa=PI3K Jnk=cJun PI3K=Akt Raf=Mek !Akt=Mek Mek=p90RSK Mek=Erk Erk=Hsp27 TNFa=Jnk TNFa=NFkB TNFa=Hsp27 EGF=Raf EGF^TNFa=PI3K Raf^!Akt=Mek Erk^TNFa=Hsp27
0 1 1 0 1 1 0 1 1 0 0 1 1 1 1 0 0
1 1 1 0 1 1 0 1 1 0 0 1 1 1 1 0 1
2 1 1 1 1 1 0 1 1 0 0 1 1 1 0 1 0

In [10]:
c.models.cnograph.midas = c.midas  # could be done automatically in the code
c.models.cnograph.png


Out[10]:

In [11]:
c.models.errorbar()



In [12]:
c.models.heatmap()


Out[12]:
<biokit.viz.heatmap.Heatmap at 0x4729f90>

Report


In [13]:
# a new page should be openned automatically in a few seconds
c.onweb()


openning report_bool/index.html

simulate


In [14]:
c.simulate(c.results.results.best_bitstring)


Out[14]:
0.0296426065162907

This function, which is actually a method could be used to solve the problem with any optimisation package.


In [15]:
def objfunc(parameters):
    return c.simulate(parameters)

objfunc([0,0,0,0, 0,0,0,0, 0,1,1,1, 1,1,1,1])


Out[15]:
0.132822472848789

In [ ]: